using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

public class GraphicColorTintGroup : View
{
    Color _color = Color.white;

    [ShowInInspector]
    public Color Color
    {
        get => _color;
        set
        {
            _color = value;
            this.SetDirty();
        }
    }

    List<Image> _graphicList;

    [ShowInInspector]
    public List<Image>  GraphicList
    {
        get
        {
            if (_graphicList == null)
            {
                var array = this.GetComponentsInChildren<Image>();
                _graphicList = array.ToList();
            }
            return _graphicList;
        }
    }

    protected override void Refresh()
    {
        this.RefreshColor();
    }

    void RefreshColor()
    {
        foreach(var g in this.GraphicList)
        {
            g.color = this.Color;
        }
    }
}
